import { defineStore } from 'pinia'
import { reqCardData, getCardList } from "../api/card"

export const useCardStore = defineStore("card", {
  state: () => {
    return {
      cardData: {},
      floorList: [],
      banner: [],
      navList: []
    }
  },
  actions: {
    async getCardData() {
      const res = await reqCardData()
      // console.log(res)
      this.cardData = res
      this.banner = res.currentCategory.bannerList
      this.floorList = res.categoryItemList
      this.navList = ((res || {}).categoryList) || []

      // console.log("cardData", this.cardData)
      // console.log("floorList", this.floorList)
      // console.log("bannerSwiper", this.banner)
      // console.log("navList9999999", this.navList)

    },

    async getCardList(id: any) {
      const result = await getCardList(id)
      // console.log('cardList', result)
      this.navList = ((result || {}).categoryList) || []
      this.banner = ((result || {}).currentCategory || {}).bannerList
      this.floorList = (result || {}).categoryItemList

      // console.log("banner888888", this.banner)
      // console.log("floorList888888", this.floorList)
      // console.log("navList66666", this.navList)
    }
  }
})